package com.hframe.http.client;

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.apache.log4j.Logger;

/**
 * Created by heqian on 12/6/16.
 */

public abstract class JsonSuccess extends StringSuccess {
    private static Logger log = Logger.getLogger(JsonSuccess.class);

    public abstract void onJson(JsonElement json);

    @Override
    public void onString(String string) {
        try {
            onJson(new JsonParser().parse(string));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
